package com.gmail.huxiaowi.cblog.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.gmail.huxiaowi.cblog.web.freemarker.FreemarkerSupport;

import freemarker.template.Template;

@Controller
@RequestMapping("/archives/*")
public class ArchiveController extends FreemarkerSupport {

    @RequestMapping
    public void handleRequest(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        Template tl = getTemplate(getServletContext(request), "/ftl", "viewArticle.ftl");
        
        Map<String, Object> dataModel = new HashMap<String, Object>();
        dataModel.put("article", userBiz.queryArticleByPostName(request.getRequestURI().substring(10)));
        tl.process(dataModel, response.getWriter());
    }

}
